< previous page page_516 next page >

Page 516
Continued
Listing 23.3
    'This next IF statement determines which and sets up the
    'SQL statement- either "Select * from table" or the
    'user-defined SQL statement.
    
    sSQL = sGetINIString(sINIPath, sSection, "SQL", "")
    If sSQL = "" Then
        Set rstemp = dbSQL.OpenRecordset("Select Count(*) from " & sSQLTable, _ 
                       dbOpenSnapshot, dbForwardOnly)
        frmWait.ProgressBar1.Max = CInt(Trim$(" 0" & rstemp.Fields(0)))
        rstemp.Close
        DoEvents
    Else
        nTemp = 2
        sTemp = sGetINIString(sINIPath, sSection, "SQL" & nTemp, "")
        While sTemp <> ""
            If sTemp <> "" Then sSQL = sSQL & sTemp
            nTemp = nTemp + 1
            sTemp = sGetINIString(sINIPath, sSection, "SQL" & nTemp, "")
        Wend
        frmWait.ProgressBar1.Max = 2000 'Set arbitrary value on progress bar
    End If
    
    
    'Actually open the recordset
    If sSQL = "" Then
        Set rstemp = dbSQL.OpenRecordset("Select * from " & sSQLTable, _ 
                       dbOpenSnapshot, dbForwardOnly)
    Else
        Set rstemp = dbSQL.OpenRecordset(sSQL, dbOpenSnapshot, dbForwardOnly + _ 
                       dbSQLPassThrough)
    End If
    
    'Open Local table
    Set aTable = dbLocal.OpenRecordset(sLocalTable, dbOpenTable)
    nFields = rstemp.Fields.Count - 1

    'Transfer each record
    While Not rstemp.EOF
        aTable.AddNew
        For nTemp = 0 To nFields
            aTable.Fields(nTemp) = rstemp.Fields(nTemp)
        Next nTemp
        rstemp.MoveNext
        nCount = nCount + 1
        frmWait.ProgressBar1.Value = nCount
        aTable.Update
    Wend
    rstemp.Close
    aTable.Close
    Exit Sub

TRTError:
    WriteErrMsg "TRT-Error " & Err & ": " & Error

 
< previous page page_516 next page >